<?php
// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

/**
* liniomenu table Class for linio Component
* 
* @package    joomla.administrator.components.linio.tables
* @subpackage components
* @author MAVLSoft - joomla! Component Creator 1.0
* @version 1.0
* @link http://www.mavlsoft.com/joomlacreator
* @license GNU General Public License version 3 or later; see http://www.gnu.org/copyleft/gpl.html
*/
class TableLiniomenu extends JTable
{
	/**
	* Primary Key (1)
	* Id Menu
	* @var int
	*/
	var $id = 0;

	/**
	* Id del padre
	* @var int
	*/
	var $parentid = 0;

	/**
	* Descripcion
	* @var string
	*/
	var $description = null;


	/**
	* Constructor
	*
	* @param object Database connector object
	*/
	function __construct(&$db)
	{
		parent::__construct( '#__liniomenu', 'id', $db );
	}
	/**
	 * (non-PHPdoc)
	 * @see JTable::store()
	 */
	function store($updateNulls=false){
		$isNew = JRequest::getVar('isNew',0);
		if( $isNew )
		{
			$ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key );
		}
		else
		{
			$ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls );
		}
		if( !$ret )
		{
			$this->setError(get_class( $this ).'::store failed - '.$this->_db->getErrorMsg());
			return false;
		}
		else
		{
			return true;
		}
	}

	/**
	 * (non-PHPdoc)
	 * @see JTable::delete()
	 */
	function delete( $oid=null )
	{
		$fmtsql = 'DELETE FROM '.$this->_db->nameQuote( $this->_tbl ).' WHERE %s';

		$k = $this->_tbl_key;
		if ($oid) {
			$this->$k = $oid;
		}
		$where = $this->_tbl_key.' = '. $this->_db->Quote($this->$k);
		$query = sprintf( $fmtsql, $where );
		$this->_db->setQuery( $query );

		if ($this->_db->query())
		{
			return true;
		}
		else
		{
			$this->setError($this->_db->getErrorMsg());
			return false;
		}
	}
}
?>